package com.heart.house.common.model;

import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;
import java.util.List;

/**
 * @author Luo Zhen
 * @create 2019-06-24 10:32
 */
@Data
public class House {

    private Long id;
    private Integer type;
    private Integer price;
    private String name;
    private String images;
    private Integer area;
    private Integer beds;
    private Integer baths;
    private Double rating;

    private String remarks;
    private String properties;
    private String floorPlan;
    private String tags;
    private Date createTime;
    private Integer cityId;
    private Integer communityId;
    private String address;
    private String firstImg;

    private List<String> imageList = Lists.newArrayList();
    private List<String> floorPlanList = Lists.newArrayList();

    private List<MultipartFile> houseFiles;
    private List<MultipartFile> floorPlanFiles;

    private Long userId;

    private boolean bookmarked;
    private Integer state;
    private List<Long> ids;
    private String sort = "time_desc";

    public void setImages(String images) {
        this.images = images;
        if (!Strings.isNullOrEmpty(images)) {
            List<String> list = Splitter.on(",").splitToList(images);
            if (!list.isEmpty()) {
                this.firstImg = list.get(0);
                this.imageList = list;
            }
        }
    }

    public void setFloorPlan(String floorPlan) {
        this.floorPlan = floorPlan;
        if (!Strings.isNullOrEmpty(floorPlan)) {
            List<String> list = Splitter.on(",").splitToList(floorPlan);
            if (!list.isEmpty()) {
                this.floorPlanList = list;
            }
        }
    }
}
